#include "NetworkException.h"

int NetworkException::NO_ERROR_CODE = 0;

NetworkException::NetworkException(std::string message)
{
	errorCode = NO_ERROR_CODE;
	customMessage = message;
}

NetworkException::NetworkException(int errorCode)
{
	this->errorCode = errorCode;
	customMessage = "";
}

NetworkException::~NetworkException()
{
}

std::string NetworkException::getMessage()
{
	std::string errorMessage;
	if (errorCode > NO_ERROR_CODE)
	{
		errorMessage = getErrorMessage(this->errorCode);
	}
	else
	{
		errorMessage = customMessage;
	}
	return errorMessage;
}

int NetworkException::getErrorCode()
{
	return errorCode;
}

std::string NetworkException::getErrorMessage(int errorCode)
{
	LPSTR errString = NULL;
     
     std::stringstream ss;
     ss << errString;
     LocalFree(errString);
     return ss.str();
}
